package com.example.demo.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Rule;
import com.example.demo.entity.rep.RuleRep;
import com.example.demo.provider.SqlProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
@Service
public interface RuleMapper extends BaseMapper<Rule> {

    //    保存 rule
    void save(Rule rule);

//    Rule update(Rule rule);

    //    更新用户
    void update(Rule rule);

//    更新最近执行时间
    int updateLastUpdateTime(String uuid, long lastExecutionTime);

    //    获取所有
    List<RuleRep> getAll();

    //    通过名称获取数据
    List<Rule> selectByName(String ruleName);

    /**
     * 自定义搜索
     * @param sql
     * @return
     */
    @SelectProvider(type = SqlProvider.class, method = "customSqlSelect")
    List<RuleRep> customSqlSelect(String sql);
}
